﻿using System;
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;

namespace Local.Service
{
    public class Utils
    {
        public static bool FileExists(string path)
        {
            bool exists = true;
            try
            {
                Task<StorageFile> fileTask = StorageFile.GetFileFromPathAsync(path).AsTask<StorageFile>();
                fileTask.Wait();
            }
            catch (Exception e)
            {
                var ae = e as AggregateException;
                if (ae != null && ae.InnerException is FileNotFoundException)
                    exists = false;
            }
            return exists;
        }

        public static async Task CheckFolder(string subFolderName)
        {
            var installFolder = ApplicationData.Current.LocalFolder;
            var apiFolder = await installFolder.CreateFolderAsync(subFolderName, CreationCollisionOption.OpenIfExists);
            
        }
    }
}
